package try_java;

import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;

class Employee {
//    private static int nextId = 1;
    private static int nextId;
    private String name;
    private double salary;
    private Date hireDay;
    private int id;
    
    static {
        Random generator = new Random();
        nextId = generator.nextInt(10000);
        
    }
    
    {
        id = nextId;
        nextId++;
        Random generator = new Random();
        GregorianCalendar calender = new GregorianCalendar(generator.nextInt(10) + 2000, generator.nextInt(11), generator.nextInt(31));
        hireDay = calender.getTime();
    }
    
    public Employee (String aName, double aSalary) {
        name = aName;
        salary = aSalary;
    }
    
    public Employee (double aSalary) {
        this("Employee #" + nextId, aSalary);
    }
    public Employee (String n, double s, int year, int month, int day) {
        name = n;
        salary = s;
        GregorianCalendar calender = new GregorianCalendar(year, month -1, day);
        hireDay = calender.getTime();
        id = 0;
    }
    
    public String getName() {
        return name;
    }
    
    public double getSalary() {
        return salary;
    }
    
    public Date getHireDay() {
        return (Date)hireDay.clone();
    }
    
    public int getId() {
        return id;
    }
    
    public void setId() {
        id = nextId;
        nextId++;
    }
    
    public static int getNextId() {
        return nextId;
    }
    
    public void raiseSalary(double byPercent) {
        double raise = salary * byPercent /100;
        salary += raise;
    }
}
